<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <!-- JS -->
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/sha1.js"></script>
    <link href="css/my.css" rel="stylesheet" type="text/css">

</head>

<body>
    <div class="section my-topsection">

        <div class="container">
            <form id="apiRegForm" class="my-form" role="form" data-toggle="validator">
                <div class="form-group">
                    <label for="appkey">应用key</label>
                    <input type="text" name="app_key" class="form-control my-tel" id="appkey" value="5C1C28D163C282474159A07E63240E68" required>
                </div>
                <div class="form-group">
                    <label for="tempkey">应用临时key</label>
                    <input type="text" class="form-control my-tel" id="tempkey" value="E27C3FB4CFC49E0DE3D5661DA3EA74BF" required>
                </div>
                <div class="form-group">
                    <label for="ext_orgCode">ext_orgCode(子账号标识)</label>
                    <input type="text" name="ext_orgCode" class="form-control my-tel" id="ext_orgCode" required>
                </div>
                <div class="form-group">
                    <label for="ext_orgName">ext_orgName(子账名字)</label>
                    <input type="text" class="form-control" id="ext_orgName" required>
                </div>
                <div class="form-group">
                    <label for="ext_orgLinker">ext_orgLinker(子账联系人)</label>
                    <input type="text" class="form-control" id="ext_orgLinker" required>
                </div>
                <div class="form-group">
                    <label for="ext_orgEmail">ext_orgEmail(子账联系人Email)</label>
                    <input type="text" class="form-control" id="ext_orgEmail" required>
                </div>
                <div class="form-group">
                    <label for="ext_orgPhone">ext_orgPhone(子账联系人手机号)</label>
                    <input type="text" name="ext_orgPhone" class="form-control" id="ext_orgPhone" required>
                </div>
                <div class="form-group">
                    <label for="signtf">sign</label>
                    <input type="text" name="sign" class="form-control" id="signtf" required>
                </div>
                <div class="form-group">
                    <label for="timestamp">timestamp</label>
                    <input type="text" class="form-control" name="timestamp" id="timestamp">
                </div>
                <div class="form-group">
                    <label for="authData">authData</label>
                    <textarea name="authData" class="form-control" id="authData" required></textarea>
                </div>
                <div class="form-group">

                    <button id="submitBtn" type="submit" class="btn btn-primary col-xs-12" onclick="javascript:void();">注册</button>
                </div>
                <div class="form-group">
                    <a id="nobody" class="btn btn-default" href="javascript:void();">nobody</a>
                </div>
            </form>

        </div>
    </div>
    <script type="text/javascript">
        $(function() {

            var getSignCode = function(apikey, temp) {
                var linkedstring = apikey + temp + $("#timestamp").val();
                debugger;
                var result = sha1.hash(linkedstring);
                return result;
            }
            var getSign = function() {
                var sign_str = getSignCode($("#appkey").val(), $("#tempkey").val());
                $("#signtf").val(sign_str);
                return sign_str;

            }
            var getAuthData = function() {
                var authData_str = '{"ext_orgName":"' + $('#ext_orgName').val() + '","ext_orgLinker":"' + $('#ext_orgLinker').val() + '","ext_orgEmail":"' + $('#ext_orgEmail').val() + '"}';
                var my_jsonstr = $.parseJSON(authData_str);
                $("#authData").val(authData_str);
                return my_jsonstr;
            }
            $("#nobody").on("click", function() {
                var result = getSign();
                getAuthData();
                alert("rs:" + result);
            });
            $("#submitBtn").on("click", function() {

                var result = getSign();
                getAuthData();
                $('form').attr("action", "http://dudu.yonyoutelecom.cn/orgacc/orgAccReg.do");
                debugger;
                $('form').submit()
            });
            $("#ext_orgName").on("change", function() {
                getAuthData();
            });
            $("#ext_orgLinker").on("change", function() {
                getAuthData();
            });
            $("#ext_orgEmail").on("change", function() {
                getAuthData();
            });
            $(document).ready(function() {
                $("#sign").val(getSign());
                var tsstr = Date.parse(new Date());
                $("#timestamp").val(tsstr);
            });

        });

        //action="http://dudu.yonyoutelecom.cn/orgacc/orgAccReg.do"

    </script>
</body>

</html>
